<template>
	<view>
		<!-- 轮播图 -->
		<view class="banner">
			<mosowe-swiper
			    :lists="imageList"
			    :touchable="false"
			    indicator="dots"
			    imageKey="img"
			    previewImage
			    pyramid
			    pyramidMargin="90rpx"
			    />
		</view>
		<!-- 导航 -->
		<view class="nav">
			<view class="nav_item" v-for="(item, index) in navs" :key="index" @click="navItemGo(item.path)">
				<view :class="item.icon">
				</view>
				<text>{{item.title}}</text>
			</view>
		</view>
		<!-- 推荐商品 -->
		<good-list :goods="goodsList"></good-list>
	</view>
</template>

<script>
	import goods_list from '../../components/goods_list/goods_list.vue'
	export default {
		data() {
			return {
				imageList: [],
				goodsList: [],
				navs: [
					{
						icon: 'iconfont icon-ziyuan',
						title: '黑马超市',
						path: '/pages/goods/goods'
					},
					{
						icon: 'iconfont icon-tupian',
						title: '社区图片',
						path: '/pages/pics/pics'
					},
					{
						icon: 'iconfont icon-guanyuwomen',
						title: '联系我们',
						path: '/pages/contact/contact'
					},
					{
						icon: 'iconfont icon-shipin',
						title: '学习视屏',
						path: '/pages/videos/videos'
					}
				]
			}
		},
		onLoad() {
			this.getImageList()
			this.getGoodsList()
		},
		methods: {
			async getImageList() {
				
				const res = await this.$httpRes({
					url:'api/getlunbo',
				})
				this.imageList = res.data.message
			},
			async getGoodsList() {
				
				const res = await this.$httpRes({
					url:'api/getgoods?pageindex=1',
				})
				this.goodsList = res.data.message
				console.log(this.goodsList)
			},
			navItemGo(url) {
				console.log(url)
				uni.navigateTo({
					url
				})
			}
		},
		components:{
			'good-list':goods_list
		}
	
	}
</script>

<style lang="scss">
	.nav{
		display: flex;
		.nav_item{
			width: 25%;
			text-align: center;
			view{
				width: 120rpx;
				height: 120rpx;
				background-color: $uni-color-background;
				border-radius: 50%;
				margin: 10px auto;
				color: #fff;
				line-height: 120rpx;
				font-size: 50rpx;
				.icon-tupian{
					font-size: 45rpx;
				}
			}
			text{
				font-size: 30rpx;
			}
		}
	}
	
</style>
